local skillName, skillRank, msg, level, name, pick
local last = 1
local group = NinjaPickerDB

local groups = {
	["Default"] = {
		"Opening lockboxes level %l or lower.",
	},
	["Org_Cash"] = {
		"%n Lockpicking Inc. Don't trust just anyone to open up your precious lockboxes, trust us! Conveniently located on top of the Ogrimmar bank. If you hit the Flight Master, you've gone too far!", -- [3]
		"Fulfulling all your level %l lockpicking needs above the Ogrimmar bank. Just open trade. Tips will make me love you.", -- [4]
		"Opening any lockbox level %l or lower on top of the Orgrimmar bank. Just open trade. Tips always greatly appreciated!", -- [6]
		"Opening any lockbox level %l or lower on top of the Orgrimmar bank. Just open trade. Tips always greatly appreciated!", -- [7]
		"GIVE ME YOUR LOCKBOXES OR I'LL STAB YOU!", -- [8]
		"Many people think I only fiddle with boxes, but that's only half of the truth! I can also delicately handle chests! That's right, I can unlock boxes AND chests! It's free and at the Orgrimmar bank!",
		"Is your large chest slowing you down? When was the last time you got some booty? Well, don't worry, I can solve both these problems! Opening level %l or lower lockboxes above the Ogrimmar bank!", -- [9]
		"im on top of ur bank, pickin ur boxez",
	},
	["Org_Free"] = {
		"Opening anything locked level %l or lower on the Orgrimmar bank for FREE! No tips necessary, I only need skill ups.",
	},
}

local function Announce(arg)
	if arg ~= "" then
		if groups[arg] then
			NinjaPickerDB = arg
			ChatFrame1:AddMessage("|cff99ff99NinjaPicker_Lite:|r Using group [\"|cffff99ff"..arg.."|r\"] ("..#groups[arg].." entries)")
		else
			for k, v in pairs(groups) do
				ChatFrame1:AddMessage(k..(NinjaPickerDB == k and "*" or ""))
			end
		end
	else
		group = NinjaPickerDB
		if not groups[group] then return end
		
		pick = random(#groups[group])
		while pick == last and #groups[group] > 1 do
			pick = random(#groups[group])
		end
		msg = (groups[group] and groups[group][pick])
		if msg then
			level, name = GetSkillRank"Lockpicking", UnitName"player"
			SendChatMessage(msg:gsub("%%n", name):gsub("%%l", level), "CHANNEL", nil, "2")
		end
		last = pick
	end
end

SLASH_NPICK1 = "/npick"
SlashCmdList["NPICK"] = Announce

